﻿using System.Reflection;

namespace Cfg.Helpers
{
    public static class ObjectExtensions
    {
        public static bool IsGreaterThan(this object o, object o2)
        {
            var type = o.GetType();
            var mi = type.GetMethod("CompareTo", new[] {type});

            var res = (int)mi.Invoke(o, new[] {o2});
            return res > 0;
        }

        public static bool IsLessThan(this object o, object o2)
        {
            var type = o.GetType();
            var mi = type.GetMethod("CompareTo", new[] { type });

            var res = (int)mi.Invoke(o, new[] { o2 });
            return res < 0;
        }
    }
}